package apps.softtech.fastmarket.model;

import android.content.ContentValues;
import android.database.Cursor;

public class ProductTag {

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public int getTagId() {
		return tagId;
	}

	public void setTagId(int tagId) {
		this.tagId = tagId;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}


	public static final String TABLE_NAME = "ProductTag";

	public static final String PRODUCT_ID = "st_ProductId";
	private int productId;

	public static final String TAG_ID = "st_TagId";
	private int tagId;

	public static final String VALUE = "st_Value";
	private String value;

	public static final String ID = "st_Id";
	private int id;

	public static final String VALUE_TYPE = "st_ValueType";
	private int valueType;

	public ProductTag() {
		super();
	}

	public ProductTag(int ptId, int tagId, String value, int id,
			int valueType) {
		super();
		this.productId = ptId;
		this.tagId = tagId;
		this.value = value;
		this.id = id;
		this.valueType = valueType;
	}

	public ProductTag(int ptId, int tagId, String value, int valueType) {
		super();
		this.productId = ptId;
		this.tagId = tagId;
		this.value = value;
		this.valueType = valueType;
	}

	/**
	 * get value of ProductTag
	 * @return ContentValue
	 */
	public ContentValues getValueProductTag(){
		ContentValues values = new ContentValues();
		values.put(PRODUCT_ID, this.getProductId());
		values.put(TAG_ID, this.getTagId());
		values.put(VALUE, this.getValue());
		return values;
	}

	public void setValueFromCursor(Cursor c) {
		
		if(c.getColumnIndex(ID)>=0){
			setId(c.getInt(c.getColumnIndex(ID)));
		}
		if(c.getColumnIndex(PRODUCT_ID)>=0){
			setProductId(c.getInt(c.getColumnIndex(PRODUCT_ID)));
		}
		if(c.getColumnIndex(TAG_ID)>=0){
			setTagId(c.getInt(c.getColumnIndex(TAG_ID)));
		}
		if(c.getColumnIndex(VALUE)>=0){
			setValue(c.getString(c.getColumnIndex(VALUE)));
		}
		
	}
}
